SpringBoot官方文档翻译(三十二):定制SpringApplication

23.3 Customizing SpringApplication(定制SpringApplication)

1
2
3
If the SpringApplication defaults are not to your taste, you can instead     
create a local instance and customize it. For example, to turn off the
banner, you could write:

如果SpringApplication默认设置不符合您的口味,您可以创建一个本地实例替换定制它。举个例子,想要关闭banner您可以这样写:

1
2
3
4
5
public static void main(String[] args) {
SpringApplication app = new SpringApplication(MySpringConfiguration.class);
app.setBannerMode(Banner.Mode.OFF);
app.run(args);
}
1
2
3
4
5
The constructor arguments passed to SpringApplication are     
configuration sources for Spring beans. In most cases, these
are references to @Configuration classes, but they could also
be references to XML configuration or to packages that should
be scanned.

传递给SpringApplication的构造函数参数是Spring bean的配置源。在大多数情况下,这将会关联到一个@Configuration的配置类,但它同样支持关联到XML配置或者关联到那些需要被扫描的包。

1
2
3
It is also possible to configure the SpringApplication by     
using an application.properties file. See Chapter 24, Externalized Configuration for details.
For a complete list of the configuration options, see the SpringApplication Javadoc.

同样可以使用application.properties来配置SpringApplication。细节请查看章节24“Externalized Configuration ”。
需要了解完整的可选配置,请查看SpringApplication的Javadoc或者源码。

分享到